<?xml version="1.0" encoding="UTF-8" ?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml"
      xmlns:ui="http://xmlns.jcp.org/jsf/facelets"
      xmlns:h="http://xmlns.jcp.org/jsf/html"
      xmlns:f="http://xmlns.jcp.org/jsf/core"
      xmlns:p="http://primefaces.org/ui">

    <ui:composition>

        <p:dialog id="PersonaEditDlg" widgetVar="PersonaEditDialog" modal="true" resizable="false" appendTo="@(body)" header="Editar Persona">
            <h:form id="PersonaEditForm">
                <h:panelGroup id="display">
                    <p:panelGrid columns="2" rendered="#{personaController.selected != null}">
                        <p:outputLabel value="Nombre razón" for="nombrerazon" />
                        <p:inputText id="nombrerazon" value="#{personaController.selected.nombrerazon}" title="#{bundle.EditPersonaTitle_nombrerazon}" required="true" requiredMessage="#{bundle.EditPersonaRequiredMessage_nombrerazon}"/>
                        <p:outputLabel value="#{bundle.EditPersonaLabel_direccion}" for="direccion" />
                        <p:inputText id="direccion" value="#{personaController.selected.direccion}" title="#{bundle.EditPersonaTitle_direccion}" required="true" requiredMessage="#{bundle.EditPersonaRequiredMessage_direccion}"/>
                        <p:outputLabel value="#{bundle.EditPersonaLabel_telefono}" for="telefono" />
                        <p:inputMask id="telefono" value="#{personaController.selected.telefono}" title="#{bundle.EditPersonaTitle_telefono}" required="true" requiredMessage="#{bundle.EditPersonaRequiredMessage_telefono}" mask="9999-9999"/>
                        <p:outputLabel value="#{bundle.EditPersonaLabel_correo}" for="correo" />
                        <p:inputText id="correo" value="#{personaController.selected.correo}" title="#{bundle.EditPersonaTitle_correo}" required="true" requiredMessage="#{bundle.EditPersonaRequiredMessage_correo}"/>
                        <p:outputLabel value="#{bundle.EditPersonaLabel_nit}" for="nit" />
                        <p:inputMask id="nit" value="#{personaController.selected.nit}" title="#{bundle.EditPersonaTitle_nit}" required="true" requiredMessage="#{bundle.EditPersonaRequiredMessage_nit}" mask="9999-999999-999-9"/>
                        <p:outputLabel value="#{bundle.EditPersonaLabel_dui}" for="dui" />
                        <p:inputMask id="dui" value="#{personaController.selected.dui}" title="#{bundle.EditPersonaTitle_dui}" required="false" requiredMessage="#{bundle.EditPersonaRequiredMessage_dui}" mask="99999999-9"/>
                        <p:outputLabel value="Representa a" for="perIdpersona" />
                        <p:selectOneMenu id="perIdpersona" value="#{personaController.selected.perIdpersona}" >
                            <f:selectItem itemLabel="#{bundle.SelectOneMessage}"/>
                            <f:selectItems value="#{personaController.itemsAvailableSelectOne}"
                                           var="perIdpersonaItem"
                                           itemValue="#{perIdpersonaItem}"/>
                        </p:selectOneMenu>
                        <p:outputLabel value="Rol de persona" for="idrolpersona" />
                        <p:selectOneMenu id="idrolpersona" value="#{personaController.selected.idrolpersona}" >
                            <f:selectItem itemLabel="#{bundle.SelectOneMessage}"/>
                            <f:selectItems value="#{rolpersonaController.itemsAvailableSelectOne}"
                                           var="idrolpersonaItem"
                                           itemValue="#{idrolpersonaItem}"/>
                        </p:selectOneMenu>
                        <p:outputLabel value="Tipo de persona" for="idtipopersona" />
                        <p:selectOneMenu id="idtipopersona" value="#{personaController.selected.idtipopersona}" required="true" requiredMessage="#{bundle.EditPersonaRequiredMessage_idtipopersona}">
                            <f:selectItem itemLabel="#{bundle.SelectOneMessage}"/>
                            <f:selectItems value="#{tipopersonaController.itemsAvailableSelectOne}"
                                           var="idtipopersonaItem"
                                           itemValue="#{idtipopersonaItem}"/>
                        </p:selectOneMenu>
                    </p:panelGrid>
                    <p:commandButton actionListener="#{personaController.update}" value="#{bundle.Save}" update="display,:PersonaListForm:datalist,:growl" oncomplete="handleSubmit(args, 'PersonaEditDialog');"/>
                    <p:commandButton value="#{bundle.Cancel}" onclick="PersonaEditDialog.hide()"/>
                </h:panelGroup>
            </h:form>
        </p:dialog>

    </ui:composition>
</html>
